package br.jus.tjpe.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class EntityManagerUtil {
	
	private static EntityManagerUtil INSTANCE;
	private static final String UNIT_NAME = "treinamentoPU";
	
	private EntityManagerFactory emf;

	public EntityManagerUtil() {
		emf = Persistence.createEntityManagerFactory(UNIT_NAME);
	}
	
	/**
	 * @return
	 */
	public static EntityManagerUtil getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new EntityManagerUtil();
		}
		return INSTANCE;
	}
	
	/**
	 * @return
	 */
	public EntityManager getEntityManager() {
		return emf.createEntityManager();
	}

}
